﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Qcdz.Domain.TreeViews;

namespace Ue.Qcdz.UI.Controls
{
    public class TreeViewGridView : Ue.Infrastructure.Web.UI.SkinnedGridView
    {
        
        private ITreeViewRepository repository;

        public TreeViewGridView()
        {
            this.repository = RepositoryFactory.GetRepository<ITreeViewRepository, Ue.Qcdz.Domain.TreeViews.TreeView>();
        }

        protected override void GridViewDataBind(object sender, EventArgs args)
        {
            IDataResult<Ue.Qcdz.Domain.TreeViews.TreeView> dataResult = this.repository.FindBy(this);

            Repeater repeater = sender as Repeater;
            repeater.DataSource = dataResult.DataObjects;
            repeater.DataBind();

            this.RecordCount = dataResult.RecordCount;
        }

        protected override string GetSkinFileName()
        {
            return "~/Admin/Themes/Skins/TreeViews/TreeViews.ascx";
        }
    }
}
